package com.fg.pro.model.trade.dto;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import lombok.Data;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;

@Data
public class GmStockSheetDto {

    @Data
    public class GmStockSheetRequest {
        public Page paging;
        public Integer stock_sheet_status;
        public Integer time_type;
        public Long begin_time;
        public Long end_time;

        @Data
        public class Page {
            public Integer limit;
            public Integer offset;
            public Boolean need_count;

            public Page(Integer limit, Integer offset, Boolean need_count) {
                this.limit = limit;
                this.offset = offset;
                this.need_count = need_count;
            }


        }

        public GmStockSheetRequest(Date start, Date end,Integer limit,Integer offset) {
            TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
            Calendar calendar = Calendar.getInstance();
            DateTime beginOfDay = DateUtil.beginOfDay(start);
            calendar.setTime(beginOfDay);
            long startTime = calendar.getTimeInMillis();
//            long startTime = beginOfDay.getTime();

            DateTime endOfDay = DateUtil.endOfDay(end);
            calendar.setTime(endOfDay);
            long endTime = calendar.getTimeInMillis();
//            long endTime = endOfDay.getTime();

            Page page = new Page(limit,offset, true);
            this.paging = page;
            this.stock_sheet_status = 4;
//            this.time_type = 3;
            this.time_type = 2;
            this.begin_time = startTime;
            this.end_time = endTime;

        }
    }

    public static void main(String[] args) {
        Long aaa = 1727711999999L;
        Date date = new Date(aaa);
        SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(sdfs.format(date));
    }

    @Data
    public class GmStockSheetReponse {
        public RepPage paging;

        public List<stockSheetData> stock_sheets;

        @Data
        public class RepPage {
            public Boolean has_more;
            public Integer count;
        }
        @Data
        public class stockSheetData{
            public Long stock_sheet_id;
            public Long create_time;
            public Long update_time;
            public Integer sheet_type;
            public Long group_id;
            public Long station_id;
            public Long target_id;
            public Integer sheet_status;
            public Long submit_time;
            public Long commit_time;
            public Long creator_id;
            public Double total_price;
            public Integer target_type;
            public Integer batch_index;
            public Integer pay_status;
            public Double tax_total_price;
            public Double product_total_price;
            public Long supplier_id;
            public Double total_price_no_tax;
            public Long warehouse_id;
            public Long submitter_id;
            public Long approver_id;
            public Integer purchase_pattern;
            public Integer detail_len;
            public String stock_sheet_serial_no;
            public Integer printed_count;
            public List<GmStockSheetDetailData> details;


            @Data
            public class GmStockSheetDetailData{
                public Long stock_sheet_detail_id;
                public Long create_time;
                public Long update_time;
                public Long group_id;
                public Long station_id;
                public Long stock_sheet_id;
                public Long sku_id;
                public Long base_unit_id;
                public Long sku_unit_id;
                public Double amount;
                public Long operator_id;
                public Long creator_id;
                public Integer input_tax;
                public Double tax_amount;
                public Double tax_input_price;
                public Double origin_tax_input_price;
                public Long shelf_id;
                public Double second_base_unit_quantity;
                public Double quantity;
                public Double price;
                public Double source_quantity;
                public Boolean use_quantity;
                public Integer sheet_type;
                public String stock_sheet_serial_no;
                public Integer sheet_status;
                public Long warehouse_id;
                public Long submit_time;
                public Long supplier_id;
                public Integer receive_status;
                public Double purchase_price;
                public Long stock_sheet_create_time;
                public Long input_unit_id;
                public Double input_unit_quantity;
                public Integer sku_batch_type;
                public Double amount_tcerror;
                public Double plan_quantity;
                public Double input_unit_plan_quantity;
                public Integer sku_is_deleted;

            }
        }
    }


}
